﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SwaggerJwtAuthenticationCenter.DbHelper.Base;
using SwaggerJwtAuthenticationCenter.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace SwaggerJwtAuthenticationCenter.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    [ApiExplorerSettings(IgnoreApi = true)]
    public class DBFirstController : ControllerBase
    {
        private readonly ILoginService _loginService;
        public DBFirstController(ILoginService loginService)
        {
            _loginService = loginService;
        }

        /// <summary>
        /// DBFirst创建模型
        /// </summary>
        /// <param name="dirPath"></param>
        /// <param name="nameSpace"></param>
        /// <returns></returns>
        [HttpGet("CreateModelFile")]
        public ResponseMsg<string> CreateModelFile(string dirPath,string nameSpace)
        {
            
            if(string.IsNullOrWhiteSpace(dirPath)||string.IsNullOrWhiteSpace(nameSpace))
            {
                return new ResponseMsg<string> { result = false, message = "参数有误，不能为空", data = "" };
            }
            return _loginService.CreateModelFile(dirPath,nameSpace);
        }
    }
}
